package com.config;

import javax.servlet.MultipartConfigElement;
import javax.servlet.ServletRegistration.Dynamic;

import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

/**
 * configure DispactherServlet
 * 
 * @author shaoyuxia
 *
 */
public class MyWebApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {

	private final static long MAX_FILE_SIZE =  1024 * 1024 * 20;
	private final static long MAX_REQUEST_SIZE =  1024 * 1024 * 30;
	private final static int FILE_SIZE_THREADHOLD =  0;
	@Override
	protected Class<?>[] getRootConfigClasses() {
		return new Class<?>[] { RootConfig.class };
	}

	@Override
	protected Class<?>[] getServletConfigClasses() {
		return new Class<?>[] { WebConfig.class };
	}

	@Override
	protected String[] getServletMappings() {
		return new String[] { "*.do" };
	}

	@Override
	protected void customizeRegistration(Dynamic registration) {
		registration.setMultipartConfig(new MultipartConfigElement("/tmp/data",MAX_FILE_SIZE, MAX_REQUEST_SIZE, FILE_SIZE_THREADHOLD));
	}

}
